﻿using System;
using UploadClient.Interfaces;

namespace UploadClient
{
    /// <summary>
    /// Serversettings
    /// </summary>
    public class ServerSettings : IEquatable<IServerSettings>, IServerSettings
    {
        #region Setting params

        public string Host {get; set; }
        public string Username { get; set; }
        public string Password { get; set; }
        public string Dir { get; set; }

        public bool Passive { get; set; }
        public int Port { get; set; }

        #endregion

        //testacc
        //====================================
        //ftp server: upload.easy-share.com
        //port: 21
        //login: ftpupload
        //pw: ftpupload
        //====================================

        #region IEquatable<IServerSettings> Members

        /// <summary>
        /// Compare Settings, return true if they are equal.
        /// </summary>
        /// <param name="settings">Settings to comapre.</param>
        /// <returns>Boolean.</returns>
        public bool Equals(IServerSettings settings)
        {
            if (Host.Equals(settings.Host) &&
                Username.Equals(settings.Username) &&
                Password.Equals(settings.Password) &&
                Dir.Equals(settings.Dir) &&
                Port.Equals(settings.Port) &&
                Passive.Equals(settings.Passive))
                return true;
            return false;
        }

        #endregion

        #region IServerSettings Members

        /// <summary>
        /// Check if Host, Username & Password is set.
        /// </summary>
        public bool isComplete()
        {
            return Host == null || Host.Equals(string.Empty) || Username == null || Password == null ? false : true;
        }

        public override int GetHashCode()
        {
            return Host.GetHashCode() ^ Username.GetHashCode() ^ Password.GetHashCode() ^ Dir.GetHashCode() ^ Passive.GetHashCode() ^ Port.GetHashCode();
        }

        public override bool Equals(object obj)
        {
            return Equals(obj as IServerSettings);
        }

        #endregion
    }
}
